home *** CD-ROM | disk | FTP | other *** search
/ Macworld Expo - Develope…Central & Net Innovations / Developer Central and Net Innovators (MacWorld Expo) (January 1999).iso / Developer Central / Bowers Development / Demo AppMaker / Examples / Pascal OS8 / Everything / ModalButtons.p < prev    next >
Encoding:
Text File  |  1998-10-30  |  5.7 KB  |  230 lines  |  [TEXT/CWIE]

  1. { ModalButtons.p -- Modal dialog }
  2. { Created 10/30/98 1:06 PM by AppMaker }
  3.  
  4. Unit ModalButtons;
  5. Interface
  6.  
  7. Uses
  8.     Types,
  9.     Quickdraw,
  10.     Controls,
  11.     Dialogs,
  12.     Events,
  13.     Lists,
  14.     Menus,
  15.     TextEdit,
  16.     AMDialog;
  17.  
  18. type
  19.     CModalButtons        = object (AMDialog)
  20.  
  21.     {data members}
  22.         mInvisibleHandle:        ControlHandle;
  23.         mStandardHandle:        ControlHandle;
  24.         mDefaultHandle:        ControlHandle;
  25.         mBevelHandle:        ControlHandle;
  26.         mButtonHandle:        ControlHandle;
  27.         mNextHandle:        ControlHandle;
  28.         mNext2Handle:        ControlHandle;
  29.         mGraphicHandle:        ControlHandle;
  30.         mRightHandle:        ControlHandle;
  31.         mLightHandle:        ControlHandle;
  32.         mRight2Handle:        ControlHandle;
  33.         mButton2Handle:        ControlHandle;
  34.         mRight3Handle:        ControlHandle;
  35.         mRect3DHandle:        ControlHandle;
  36.         mLeftIconHandle:        ControlHandle;
  37.         mRightIconHandle:        ControlHandle;
  38.         mTitledPICTHandle:        ControlHandle;
  39.         mOKHandle:        ControlHandle;
  40.  
  41.     {methods - public}
  42.         Procedure ConnectToData    (inData:    AMSignaler); Override;
  43.  
  44.     {methods - internal}
  45.         Procedure FinishMake; Override;
  46.         Procedure DoItem    (inItemHit:    SInt16); Override;
  47.         Procedure DataChanged    (inDataID:    longint); Override;
  48.  
  49.     end;
  50.  
  51. {----------}
  52. Function NewModalButtons: CModalButtons;
  53.  
  54. {----------}
  55. Function GetModalButtons: Boolean;
  56.  
  57. {----------}
  58. Implementation
  59.  
  60. Uses
  61.     ResourceDefs,
  62.     ControlUtils,
  63.     Miscellany;
  64.  
  65. const
  66.     kCapInvisibleLabel        = 1;
  67.     kInvisibleButton        = 2;
  68.     kStandardButton        = 3;
  69.     kDefaultButton        = 4;
  70.     kBevelBox        = 5;
  71.     kButtonButton        = 6;
  72.     kNextButton        = 7;
  73.     kNext2Button        = 8;
  74.     kGraphicBox        = 9;
  75.     kCapcicnLabel        = 10;
  76.     kRightButton        = 11;
  77.     kCapicl8Label        = 12;
  78.     kLightButton        = 13;
  79.     kCapICNLabel        = 14;
  80.     kRight2Button        = 15;
  81.     kCapicl9Label        = 16;
  82.     kButton2Button        = 17;
  83.     kCapPICTLabel        = 18;
  84.     kRight3Button        = 19;
  85.     kRect3DButton        = 20;
  86.     kLeftIconButton        = 21;
  87.     kRightIconButton        = 22;
  88.     kTitledPICTButton        = 23;
  89.     kOKButton        = 24;
  90.  
  91.  
  92. {----------}
  93. Function NewModalButtons: CModalButtons;
  94. var
  95.     dialog:        CModalButtons;
  96. begin
  97.     dialog := nil;
  98.     New (dialog);
  99.  
  100.     if dialog <> nil then begin
  101.         dialog.Initialize;
  102.     end;
  103.     NewModalButtons := dialog;
  104. end;
  105.  
  106. {----------}
  107. Function GetModalButtons: Boolean;
  108. var
  109.     result:            Boolean;
  110.     dialog:            CModalButtons;
  111. begin
  112.     result := false;
  113.     dialog := NewModalButtons;
  114.  
  115.     result := dialog.RunModal (DLOG_ModalButtons, nil);
  116.  
  117.     dialog.Free;
  118.     Dispose (dialog);
  119.  
  120.     GetModalButtons := result;
  121. end;
  122.  
  123. {----------}
  124. Procedure CModalButtons.FinishMake;
  125. var
  126.     errCode:        OSErr;
  127. begin
  128.     mInvisibleHandle := GetControlItem (kInvisibleButton);
  129.     mStandardHandle := GetControlItem (kStandardButton);
  130.     mDefaultHandle := GetControlItem (kDefaultButton);
  131.     SetDefaultState (mDefaultHandle, true);
  132.     errCode := SetDialogDefaultItem (mDialog, kDefaultButton);
  133.     mBevelHandle := GetControlItem (kBevelBox);
  134.     mButtonHandle := GetControlItem (kButtonButton);
  135.     errCode := SetBevelButtonGraphicAlignment (mButtonHandle, kControlBevelButtonAlignCenter, 0, 0);
  136.     mNextHandle := GetControlItem (kNextButton);
  137.     errCode := SetBevelButtonTextPlacement (mNextHandle, kControlBevelButtonPlaceToRightOfGraphic);
  138.     errCode := SetBevelButtonTextAlignment (mNextHandle, kControlBevelButtonAlignTextFlushLeft, 0);
  139.     errCode := SetBevelButtonGraphicAlignment (mNextHandle, kControlBevelButtonAlignLeft, 0, 0);
  140.     mNext2Handle := GetControlItem (kNext2Button);
  141.     errCode := SetBevelButtonTextPlacement (mNext2Handle, kControlBevelButtonPlaceBelowGraphic);
  142.     errCode := SetBevelButtonTextAlignment (mNext2Handle, kControlBevelButtonAlignTextCenter, 0);
  143.     errCode := SetBevelButtonGraphicAlignment (mNext2Handle, kControlBevelButtonAlignTop, 0, 0);
  144.     mGraphicHandle := GetControlItem (kGraphicBox);
  145.     mRightHandle := GetControlItem (kRightButton);
  146.     mLightHandle := GetControlItem (kLightButton);
  147.     mRight2Handle := GetControlItem (kRight2Button);
  148.     mButton2Handle := GetControlItem (kButton2Button);
  149.     mRight3Handle := GetControlItem (kRight3Button);
  150.     mRect3DHandle := GetControlItem (kRect3DButton);
  151.     mLeftIconHandle := GetControlItem (kLeftIconButton);
  152.     mRightIconHandle := GetControlItem (kRightIconButton);
  153.     mTitledPICTHandle := GetControlItem (kTitledPICTButton);
  154.     mOKHandle := GetControlItem (kOKButton);
  155.     SetDefaultState (mOKHandle, true);
  156.     errCode := SetDialogDefaultItem (mDialog, kOKButton);
  157. end;
  158.  
  159. {----------}
  160. Procedure CModalButtons.ConnectToData (
  161.     inData:        AMSignaler); Override;
  162. begin
  163.     inherited ConnectToData (inData);
  164.  
  165. end;
  166.  
  167. {----------}
  168. Procedure CModalButtons.DoItem (
  169.     inItemHit:        SInt16);
  170. begin
  171.     case inItemHit of
  172.     kInvisibleButton:
  173.             ;{? this button doesn't have a command }
  174.             { DoInvisibleButton; }
  175.     kStandardButton:
  176.             ;{? this button doesn't have a command }
  177.             { DoStandardButton; }
  178.     kDefaultButton:
  179.             ;{? this button doesn't have a command }
  180.             { DoDefaultButton; }
  181.     kButtonButton:
  182.             ;{? this button doesn't have a command }
  183.             { DoButtonButton; }
  184.     kNextButton:
  185.             ;{? this button doesn't have a command }
  186.             { DoNextButton; }
  187.     kNext2Button:
  188.             ;{? this button doesn't have a command }
  189.             { DoNext2Button; }
  190.     kRightButton:
  191.             ;{? this button doesn't have a command }
  192.             { DoRightButton; }
  193.     kLightButton:
  194.             ;{? this button doesn't have a command }
  195.             { DoLightButton; }
  196.     kRight2Button:
  197.             ;{? this button doesn't have a command }
  198.             { DoRight2Button; }
  199.     kButton2Button:
  200.             ;{? this button doesn't have a command }
  201.             { DoButton2Button; }
  202.     kRight3Button:
  203.             ;{? this button doesn't have a command }
  204.             { DoRight3Button; }
  205.     kRect3DButton:
  206.             ;{? this button doesn't have a command }
  207.             { DoRect3DButton; }
  208.     kLeftIconButton:
  209.             ;{? this button doesn't have a command }
  210.             { DoLeftIconButton; }
  211.     kRightIconButton:
  212.             ;{? this button doesn't have a command }
  213.             { DoRightIconButton; }
  214.     kTitledPICTButton:
  215.             ;{? this button doesn't have a command }
  216.             { DoTitledPICTButton; }
  217.     kOKButton:
  218.             SetResult (true);
  219.  
  220.     end; {switch}
  221. end;
  222.  
  223. {----------}
  224. Procedure CModalButtons.DataChanged (
  225.     inDataID:        longint); Override;
  226. begin
  227. end;
  228.  
  229. End.
  230.